home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / c / path.c < prev    next >
C/C++ Source or Header  |  1996-09-13  |  2KB  |  80 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: path.c,v 1.3 1996/09/13 17:52:11 digulla Exp $
  4.     $Log: path.c,v $
  5.     Revision 1.3  1996/09/13 17:52:11  digulla
  6.     Use IPTR
  7.  
  8.     Revision 1.2  1996/08/01 17:40:45  digulla
  9.     Added standard header for all files
  10.  
  11.     Desc:
  12.     Lang:
  13. */
  14. #include <exec/memory.h>
  15. #include <clib/exec_protos.h>
  16. #include <dos/dosextens.h>
  17. #include <clib/dos_protos.h>
  18.  
  19. CALLENTRY /* Before the first symbol */
  20.  
  21. struct ExecBase *SysBase;
  22. struct DosLibrary *DOSBase;
  23.  
  24. static LONG tinymain(void);
  25.  
  26. LONG entry(struct ExecBase *sysbase)
  27. {
  28.     LONG error=RETURN_FAIL;
  29.     SysBase=sysbase;
  30.     DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",39);
  31.     if(DOSBase!=NULL)
  32.     {
  33.     error=tinymain();
  34.     CloseLibrary((struct Library *)DOSBase);
  35.     }
  36.     return error;
  37. }
  38.  
  39. static LONG tinymain(void)
  40. {
  41.     struct RDArgs *rda;
  42.     IPTR args[6]={ 0, 0, 0, 0, 0, 0 };
  43.  
  44.     rda=ReadArgs("PATH/M,ADD/S,SHOW/S,RESET/S,REMOVE/S,QUIET/S",args,NULL);
  45.     if(rda!=NULL)
  46.     {
  47.     STRPTR *names=(STRPTR *)args[0];
  48.     BPTR *cur, *next;
  49.     struct CommandLineInterface *cli;
  50.     cli=Cli();
  51.     cur=(BPTR *)BADDR(cli->cli_CommandDir);
  52.     while(cur)
  53.     {
  54.         next=(BPTR *)cur[0];
  55.         UnLock(cur[1]);
  56.         FreeVec(cur);
  57.         cur=next;
  58.     }
  59.     cur=&cli->cli_CommandDir;
  60.     while(*names!=NULL)
  61.     {
  62.         next=(BPTR *)AllocVec(2*sizeof(BPTR),MEMF_ANY);
  63.         next[1]=Lock(*names,SHARED_LOCK);
  64.         if(!next[1])
  65.         {
  66.         FreeVec(next);
  67.         break;
  68.         }
  69.         cur[0]=MKBADDR(next);
  70.         cur=next;
  71.         if(!args[5])
  72.         VPrintf("%s added.\n",(ULONG *)names);
  73.         names++;
  74.     }
  75.     cur[0]=0;
  76.     FreeArgs(rda);
  77.     }
  78.     return 0;
  79. }
  80.